package com.gw.detail.controllor.detail;

import com.gw.detail.domain.Fzg;
import com.gw.detail.service.IFzgService;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 车辆数据Controller
 *
 * @author WangBin
 * @date 2021-04-30
 */
@RestController
@RequestMapping("/detail/fzg")
public class FzgController extends BaseController {
    @Autowired
    private IFzgService fzgService;

    /**
     * 查询车辆数据列表
     */
    @PreAuthorize("@ss.hasPermi('detail:fzg:list')")
    @GetMapping("/list")
    public TableDataInfo list(Fzg fzg) {
        startPage();
        List<Fzg> list = fzgService.selectFzgList(fzg);
        return getDataTable(list);
    }

    /**
     * 导出车辆数据列表
     */
    @PreAuthorize("@ss.hasPermi('detail:fzg:export')")
    @Log(title = "车辆数据", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(Fzg fzg) {
        List<Fzg> list = fzgService.selectFzgList(fzg);
        ExcelUtil<Fzg> util = new ExcelUtil<Fzg>(Fzg.class);
        return util.exportExcel(list, "车辆数据数据");
    }

    /**
     * 获取车辆数据详细信息
     */
    @PreAuthorize("@ss.hasPermi('detail:fzg:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(fzgService.selectFzgById(id));
    }

    /**
     * 新增车辆数据
     */
    @PreAuthorize("@ss.hasPermi('detail:fzg:add')")
    @Log(title = "车辆数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Fzg fzg) {
        return toAjax(fzgService.insertFzg(fzg));
    }

    /**
     * 修改车辆数据
     */
    @PreAuthorize("@ss.hasPermi('detail:fzg:edit')")
    @Log(title = "车辆数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Fzg fzg) {
        return toAjax(fzgService.updateFzg(fzg));
    }

    /**
     * 删除车辆数据
     */
    @PreAuthorize("@ss.hasPermi('detail:fzg:remove')")
    @Log(title = "车辆数据", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(fzgService.deleteFzgByIds(ids));
    }
}
